﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using webapp4U.DAL;

/// <summary>
/// Summary description for Products
/// </summary>
/// 
namespace webapp4U.BOL
{
    public class Products : BizObject
    {
        #region Member Variables
        private String _inclasskey;
        private String _itemkey;
        private String _description;
        private float _unitPrice;
        private String _imageUrl;
        #endregion

        #region Public Properties
        public String InClassKey
        {
            get { return _inclasskey; }
            set { _inclasskey = value; }
        }
        public String ItemKey
        {
            get { return _itemkey; }
            set { _itemkey = value; }
        }
        public String Description
        {
            get { return _description; }
            set { _description = value; }
        }
        public float UnitPrice
        {
            get { return _unitPrice; }
            set { _unitPrice = value; }
        }
        public String ImageUrl
        {
            get { return _imageUrl; }
            set { _imageUrl = value; }
        }
        #endregion

        #region public static Methods
        public static List<Products> GetProductsByInClassKey(string InClassKey, int PageIndex, int PageSize, ref string error)
        {
            ProductsDAL db = new ProductsDAL();
            return db.GetProductsByInClassKey(InClassKey, PageIndex, PageSize, ref error);
        }

        public static List<Products> GetProductsByCommodKey(string CommodKey, int PageIndex, int PageSize, ref string error)
        {
            ProductsDAL db = new ProductsDAL();
            return db.GetProductsByCommodKey(CommodKey, PageIndex, PageSize, ref error);
        }

        // Get ProductsCountByCateID
        public static int GetProductsCountByInClassKey(String InClassKey, ref string error)
        {
            ProductsDAL db = new ProductsDAL();
            return db.GetProductsCountByInClassKey(InClassKey, ref error);
        }

        public static int GetProductsCountByCommodKey(String CommodKey, ref string error)
        {
            ProductsDAL db = new ProductsDAL();
            return db.GetProductsCountByCommodKey(CommodKey, ref error);
        }

        public static Products GetProductsByItemKey(string ItemKey, ref string error)
        {
            ProductsDAL db = new ProductsDAL();
            return db.GetProductsByItemKey(ItemKey, ref error);
        }

        //Get All Products
        public static List<Products> GetAllProducts(ref string error)
        {
            ProductsDAL db = new ProductsDAL();
            return db.GetAllProducts(1, MAXROWS,ref error);
        }

        //Get All Products
        public static List<Products> GetAllProducts(int PageIndex, int PageSize, ref string error)
        {
            ProductsDAL db = new ProductsDAL();
            return db.GetAllProducts(PageIndex, PageSize, ref error);
        }

        public static List<Products> GetTop6Product(string InClassKey,ref string error)
        {
            ProductsDAL db = new ProductsDAL();
            return db.GetTop6Product(InClassKey,ref error);
        }

        public static List<Products> GetTop6ProductByCommod(string CommodKey, ref string error)
        {
            ProductsDAL db = new ProductsDAL();
            return db.GetTop6ProductByCommod(CommodKey, ref error);
        }
        public static string GetImageUrlByID(string ItemKey)
        {
            string error = "";
            try
            {
                Products obj = Products.GetProductsByItemKey(ItemKey,ref error);
                return obj.ImageUrl;
            }
            catch { return ""; }
        }

        #endregion

        
               
    }
}